package com.zy.design.ddd.domain.wallet.repository;

import com.zy.design.ddd.domain.wallet.entity.VirtualWalletEntity;

import java.math.BigDecimal;

/**
 * @author zhaoyi
 * @date 2021/2/5 16:08
 * 模拟操作数据库
 */
public class VirtualWalletRepository {


    public VirtualWalletEntity getWalletEntity(Long walletId) {
        boolean b = walletId / 2 == 0;
        BigDecimal overdraftAmount = b ? BigDecimal.valueOf(20) : BigDecimal.ZERO;
        return new VirtualWalletEntity(walletId, BigDecimal.valueOf(90), b, overdraftAmount, BigDecimal.valueOf(10));
    }

    public void updateBalance(Long walletId, BigDecimal balance) {
        System.out.println("更新" + walletId + "的余额为" + balance);
    }
}
